package com.chat.chat.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chat.chat.dao.LoginParamDao;
import com.chat.chat.beans.LoginParam;
import com.chat.chat.entity.User;
import com.chat.chat.service.FaceService;
import com.chat.chat.service.LoginParamService;
import com.chat.chat.service.SysUserService;
import com.chat.chat.service.UserService;
import com.chat.chat.untils.JwtUtil_blog;
import com.chat.chat.untils.MD5;
import com.font.utils.JwtUtil_graph;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * (LoginParam)表服务实现类
 *
 * @author makejava
 * @since 2024-03-14 15:52:18
 */
@Service("loginParamService")
public class LoginParamServiceImpl extends ServiceImpl<LoginParamDao, LoginParam> implements LoginParamService {

    @Autowired
    LoginParamDao loginParamDao;


    @Override
    public void regiter(LoginParam loginParam) {

        loginParam.setPassWord(MD5.encrypt(loginParam.getPassWord()));
        int insert = loginParamDao.insert(loginParam);
    }

    @Override
    public Map<String, Object> login(LoginParam loginParam) {
        HashMap<String, Object> map = new HashMap<>();

        String blog_token = JwtUtil_blog.createJWT(loginParam.getId().toString());

        HashMap<String, String> faceMap = new HashMap<>();
        faceMap.put("faceName", loginParam.getName());
        String graph_token = JwtUtil_graph.genereteToken(faceMap);

        map.put("graph_token",graph_token);
        map.put("blog_token",blog_token);

        return map;
    }

}

